package xin.marcher.module.rights.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xin.marcher.module.common.core.JsonResult;
import xin.marcher.module.rights.api.RoleApi;
import xin.marcher.module.rights.domain.request.QueryRoleRequest;
import xin.marcher.module.rights.domain.request.RemoveRoleRequest;
import xin.marcher.module.rights.domain.request.RoleRequest;

/**
 *
 */
@RestController
@RequestMapping("/rights/role")
public class RoleController {

    @Autowired
    private RoleApi roleApi;

    /**
     * 添加角色
     */
    @PreAuthorize("@rights.check('saveRole')")
    @PostMapping("/saveRole")
    public JsonResult saveRole(RoleRequest request) {
        return roleApi.saveRole(request);
    }

    /**
     * 删除角色
     */
    @PreAuthorize("@rights.check('removeRole')")
    @PostMapping("/removeRole")
    public JsonResult removeRole(RemoveRoleRequest request) {
        return roleApi.removeRole(request);
    }

    /**
     * 查询角色列表
     */
    @PreAuthorize("@rights.check('queryRole')")
    @PostMapping("/queryRole")
    public JsonResult queryRole(QueryRoleRequest request) {
        return roleApi.queryRole(request);
    }

}
